import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/chat'
  },
  {
    path: '/chat',
    name: 'chat',
    component: () => import('../views/ChatView.vue')
  },
  {
    path: '/group',
    name: 'group',
    component: () => import('../views/GroupView.vue')
  },
  {
    path: '/docs',
    name: 'docs',
    component: () => import('../views/DocsView.vue')
  },
  {
    path: '/ai',
    name: 'ai',
    component: () => import('../views/AIView.vue')
  },
  {
    path: '/knowledge',
    name: 'knowledge',
    component: () => import('../views/KnowledgeView.vue')
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('../views/SettingView.vue')
  },
  {
    path: '/newList',
    name: 'newList',
    component: () => import('../views/news/NewList.vue')
  },
  {
    path: '/newDetails',
    name: 'newDetails',
    component: () => import('../views/news/NewDetails.vue')
  },
  {
    path: '/aiVideoCreate',
    name: 'aiVideoCreate',
    component: () => import('../views/aiVideo/index.vue')
  }
];

const router = new VueRouter({
  mode: 'history',
  base: '/',
  routes
});

// 全局捕获 NavigationDuplicated 错误
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
};

export default router;